const { mainModule } = require('process');
var handler = require('./handler.js');

function testCalculateVector(){
    let vector = handler.calculateVector([-1,-1,1,0],-1);
    console.log(JSON.stringify(vector));
}

function testRemoveOtherChess(){
    let vector = handler.removeOtherChess([-1,-1,1,0],1);
    console.log(JSON.stringify(vector));
}


function testGetRemoveList(){
    let room={};
    room.board = [
        [0,-1,0,0],
        [0,1,0,0],
        [0,1,0,0],
        [0,0,0,0]
    ];
    let i = 2;
    let j = 1;
    let playerValue = 1;
    let removeList = handler.getRemoveList(room,i,j,playerValue);
    console.log(JSON.stringify(removeList));

}

function testGetRoomById(){
    let rooms = [{board:[
        [0,1,0,0],
        [0,1,0,0],
        [0,1,0,0],
        [0,1,0,0]
    ],former:'wang',later:'maio',roomId:123}];
    let roomId = 123;
    handler.setRooms(rooms);
    let room = handler.getRoomById(roomId);
    console.log(JSON.stringify(room));
}


function testCheckWin(){
    let rooms = [{board:[
        [0,-1,0,0],
        [0,-1,-1,1],
        [0,-1,-1,1],
        [1,-1,-1,0]
    ],former:'wang',later:'maio',roomId:123}];
    let request = {roomId:123};
    let response = {end:function(string){
        console.log(string);
    }};
    
    handler.setRooms(rooms);
    handler.checkWin(request,response);
}


//estCalculateVector();
//testRemoveOtherChess();
//testGetRemoveList();
//testGetRoomById();
testCheckWin();